package hotel.base.oversea.config;

import org.springframework.stereotype.Component;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @Author lmf
 * @Date 2020/5/22 10:32
 * 获取当前服务的ip和端口
 **/
@Component
public class ServerConfig {
    /**
     * @return
     * 获取ip地址
     */
    public String getHostAddress(){
        InetAddress address=null;
        try {
            address=InetAddress.getLocalHost();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return address.getHostAddress();
    }
}
